﻿var validator = new FormValidator('register', 
[{
	name: 'registerInfo.account',  
	display: 'tài khoản',
	rules: 'required|alpha_numeric|min_length[6]|max_length[20]'
},{
	name: 'registerInfo.password',  
	display: 'mật khẩu',
	rules: 'required|alpha_numeric|min_length[6]|max_length[12]'
},{
	name: 'rePassword',  
	display: 'xác nhận mật khẩu',
	rules: 'required|matches[registerInfo.password]'
},{
	name: 'registerInfo.email',  
	display: 'email',
	rules: 'required|valid_email|min_length[6]|max_length[50]'
},{
	name: 'registerInfo.firstName',  
	display: 'họ',
	rules: 'required|min_length[1]|max_length[20]'
},{
	name: 'registerInfo.lastName',  
	display: 'tên',
	rules: 'required|min_length[1]|max_length[20]'
},{
	name: 'registerInfo.address',  
	display: 'địa chỉ',
	rules: 'required|min_length[1]|max_length[50]'
},{
	name: 'registerInfo.phoneNumber',  
	display: 'số điện thoại',
	rules: 'required|is_natural|min_length[1]|max_length[14]'
},{
	name: 'registerInfo.secretAnswer',  
	display: 'câu trả lời bí mật',
	rules: 'required|min_length[6]|max_length[50]'
},{
	name: 'day',  
	display: 'ngày sinh',
	rules: 'is_natural'
},{
	name: 'month',  
	display: 'tháng sinh',
	rules: 'is_natural'
},{
	name: 'year',  
	display: 'năm sinh',
	rules: 'is_natural'
},{
	name: 'registerInfo.secretQuestion',  
	display: 'câu hỏi bí mật',
	rules: 'is_natural_no_zero'
}], function(errors, evt) {
			var SELECTOR_ERRORS = $('.error_box'),
			SELECTOR_SUCCESS = $('.success_box');
			
		if (errors.length > 0) {
			SELECTOR_ERRORS.empty();
			for (var i = 0, errorLength = errors.length; i < errorLength; i++) {
				SELECTOR_ERRORS.append(errors[i].message + '<br />');
			}
			
			SELECTOR_SUCCESS.css({ display: 'none' });
			SELECTOR_ERRORS.fadeIn(200);
		} else {
			SELECTOR_ERRORS.css({ display: 'none' });
			SELECTOR_SUCCESS.fadeIn(200);
		}			
	});